# -*- coding: utf-8 -*- 

import wx
import time
import random
import pymouse
  
#import the newly created GUI file 
import main  
class MainFrame(main.MyFrame1): 
    def __init__(self,parent): 
        main.MyFrame1.__init__(self,parent)  

    def submit(self,event): 
        #获取参数
        x_l = int(self.m_textCtrl1.GetValue().encode('utf-8')) #横坐标左
        x_r = int(self.m_textCtrl2.GetValue().encode('utf-8')) #横坐标右
        y_t = int(self.m_textCtrl3.GetValue().encode('utf-8')) #纵坐标上
        y_b = int(self.m_textCtrl4.GetValue().encode('utf-8')) #纵坐标下
        total = int(self.m_textCtrl5.GetValue().encode('utf-8')) #时间
        spacing = int(self.m_textCtrl6.GetValue().encode('utf-8')) #间隔
        count = 0 #初始
        #数据处理
        end_time = int(time.time()) + total
        #循环处理
        while (int(time.time()) <= end_time):
            x = random.randint(x_l, x_r)
            y = random.randint(y_t, y_b)
            m = pymouse.PyMouse()
            m.position()#获取当前坐标的位置
            m.move(x,y)#鼠标移动到xy位置
            m.click(x,y)#移动并且在xy位置点击
            count = count + 1
            time.sleep(spacing)
            #m.click(x,y,1|2)#移动并且在xy位置点击,左右键点击
      
    def cancle(self,event): 
        return
        
app = wx.App(False) 
frame = MainFrame(None) 
frame.Show(True) 
#start the applications 
app.MainLoop()  